#!/usr/bin/env python
# --*-- encoding:utf-8 --*-- 

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

#设置服务器，用户名、口令以及邮箱的后缀
mail_host="smtp.gmail.com"
mail_user="ad@fengsage.com"
mail_pass="sd145914sd"



def send_mail(to, subject, text):
    msg = MIMEMultipart()
    msg['From'] = mail_user
    msg['To'] = to
    msg['Subject'] = subject

    msg.attach(MIMEText(text))

    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(mail_user, mail_pass)
    mailServer.sendmail(mail_user, to, msg.as_string())
    mailServer.close()
   
   
if __name__=="__main__":
    send_mail("me@fengsage.com","111111","2")
    
    